package cmpp.netty;

import java.util.UUID;

import org.apache.log4j.Logger;

/**
 * ID生成工具
 * 
 */
public class UtilsUtils {

	@SuppressWarnings("unused")
	private static Logger log = Logger.getLogger(UtilsUtils.class);

	/**
	 * 获取UUID by jdk
	 * 
	 * @return
	 */
	public static String getUuidByJdk(boolean is32bit) {
		String uuid = UUID.randomUUID().toString();
		if (is32bit) {
			return uuid.toString().replace("-", "");
		}
		return uuid;
	}

	/**
	 * ID生成方法
	 * 
	 * @param lg
	 * @return
	 */
	public static String getRandomId(int lg) {
		String uuid = getUuidByJdk(true);
		return "F" + uuid.substring(0, lg);
	}

	/**
	 * 获取订ID
	 * 
	 * @param lg
	 * @return
	 */
	public static String getOrderId(int lg, String prefix) {
		String uuid = getUuidByJdk(true);
		return prefix + uuid.substring(0, lg);
	}

}
